package test;

import java.awt.Rectangle;
import java.util.Random;

public class Buff {
	public int x;
	public int y;
	int num=0;
	int q=5;
	public final int WIDTH=50;
	public final int HEIGHT=50;
	public static GameStart gs=new GameStart();
	public static GameOver go=new GameOver();
	public Buff(){
			Random ra=new Random();
			int randomNum=ra.nextInt(GameWindows.WIN_WIDTH-68);
			this.x=randomNum;
			this.y=0;
	}
	public void move(){
		this.y+=1;
		this.x+=q;
		if(this.x>=850){
			q=-5;
		}
		if(this.x<=0){
			q=5;
		}
	}
	public boolean hit(MyPlane mp){
		boolean b=false;
		Rectangle bfRect=new Rectangle(this.x,this.y,this.WIDTH,this.HEIGHT);
		Rectangle mpRect=new Rectangle(mp.x,mp.y,mp.WIDTH,mp.HEIGHT);
		b=mpRect.intersects(bfRect);
		return b;
	}
	public boolean hit1(PlaneTwo pt){
		boolean b=false;
		Rectangle bfRect=new Rectangle(this.x,this.y,this.WIDTH,this.HEIGHT);
		Rectangle mpRect=new Rectangle(pt.x,pt.y,pt.WIDTH,pt.HEIGHT);
		b=mpRect.intersects(bfRect);
		return b;
	}
	public void BuffMake() {
		if(gs.start&&go.stop==false){
			Buff bf=new Buff();
			GameWindows.bfList.add(bf);
		}
	}
}
